<!doctype html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Dashboard Template for Bootstrap</title>
    <!-- Bootstrap 核心CSS -->
    <link rel="stylesheet" href="../../static/css/bootstrap.min.css" th:href="@{/static/css/bootstrap.min.css}">
    <link rel="stylesheet" href="../../static/css/font-awesome.min.css" th:href="@{/static/css/font-awesome.min.css}">

    <!-- Meta关键字定义 -->
    <meta name="description" content="The most popular HTML, CSS, and JS library in the world.">
    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">

    <style>
        body {font-size: .875rem;}
        .feather {width: 16px;height: 16px;vertical-align: text-bottom;}
        .sidebar {position: fixed;top: 0;bottom: 0;left: 0;z-index: 100;padding: 0;box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);}
        .sidebar-sticky {position: -webkit-sticky;position: sticky;top: 48px; height: calc(100vh - 48px);padding-top: .5rem;overflow-x: hidden;overflow-y: auto; }
        .sidebar .nav-link {font-weight: 500;color: #333;}
        .sidebar .nav-link .feather {margin-right: 4px;color: #999;}
        .sidebar .nav-link.active {color: #007bff;}
        .sidebar .nav-link:hover .feather,.sidebar .nav-link.active .feather {color: inherit;}
        .sidebar-heading {font-size: .75rem;text-transform: uppercase;}
        .navbar-brand {padding-top: .75rem;padding-bottom: .75rem;font-size: 1rem;background-color: rgba(0, 0, 0, .25);box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);}
        .navbar .form-control {padding: .75rem 1rem;border-width: 0;border-radius: 0;}
        .form-control-dark {color: #fff;background-color: rgba(255, 255, 255, .1);border-color: rgba(255, 255, 255, .1);}
        .form-control-dark:focus {border-color: transparent;box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);}
        .border-top { border-top: 1px solid #e5e5e5; }
        .border-bottom { border-bottom: 1px solid #e5e5e5; }
    </style>
</head>
<body>
    <nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0">
        <a class="navbar-brand col-sm-3 col-md-2 mr-0" href="#">Company name</a>
        <input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">
        <button class="btn-dark btn"  style="width: 20%" type="submit">搜索</button>
        <ul class="navbar-nav px-3">
            <li class="nav-item text-nowrap">
                <a class="nav-link" href="#">Sign out</a>
            </li>
        </ul>
    </nav>
    <div class="container-fluid">
        <div class="row">
            <nav class="col-md-2 d-none d-md-block bg-light sidebar">
                <div class="sidebar-sticky">
                    <ul class="nav flex-column">
                        <li class="nav-item">
                            <a class="nav-link active" href="/dashboard">
                                <span data-feather="home"></span>
                                分析 <span class="sr-only">(current)</span>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="/orders">
                                <span data-feather="file"></span>
                                未处理订单
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="/returns">
                                <span data-feather="file"></span>
                                退货单
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="/historyOrders">
                                <span data-feather="file"></span>
                                历史处理订单
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="/goods">
                                <span data-feather="shopping-cart"></span>
                                商品
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                <span data-feather="bar-chart-2"></span>
                                Reports
                            </a>
                        </li>
                    </ul>

                    <h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
                        <span>Saved reports</span>
                        <a class="d-flex align-items-center text-muted" href="#">
                            <span data-feather="plus-circle"></span>
                        </a>
                    </h6>
                    <ul class="nav flex-column mb-2">
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                <span data-feather="file-text"></span>
                                Current month
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                <span data-feather="file-text"></span>
                                Last quarter
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                <span data-feather="file-text"></span>
                                Social engagement
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                <span data-feather="file-text"></span>
                                Year-end sale
                            </a>
                        </li>
                    </ul>
                </div>
            </nav>

            <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
                <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
                    <h1 class="h2">Dashboard</h1>
                    <div class="btn-toolbar mb-2 mb-md-0">
                        <div class="btn-group mr-2">
                            <a href="/" class="btn btn-sm btn-outline-secondary">首页</a>
                            <button class="btn btn-sm btn-outline-secondary">Share</button>
                            <button class="btn btn-sm btn-outline-secondary">Export</button>
                        </div>
                        <button class="btn btn-sm btn-outline-secondary dropdown-toggle">
                            <span data-feather="calendar"></span>
                            This week
                        </button>
                    </div>
                </div>

                <canvas class="my-4" id="myChart" width="900" height="380"></canvas>
                <div id="table" class="table-responsive">
                    <table class="table table-striped table-sm">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>name</th>
                            <th>buying_price</th>
                            <th>selling_price</th>
                            <th>place</th>
                            <th>state</th>
                            <th>times</th>
                            <th>type</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="good:${goods}">
                            <td th:text="${good.id}"></td>
                            <td th:text="${good.name}"></td>
                            <td th:text="${good.buying_price}"></td>
                            <td th:text="${good.selling_price}"></td>
                            <td th:text="${good.place}"></td>
                            <td th:text="${good.state}"></td>
                            <td th:text="${good.times}"></td>
                            <td th:text="${good.type}"></td>
                            <td>
                                <a  th:href="@{/analyse/}+${good.id}" class="btn btn-sm btn-primary" >查看</a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </main>
        </div>
    </div>

<!-- Bootstrap 核心 JavaScript -->
<script type="text/javascript" src="../../static/js/jquery-3.3.1.js" th:src="@{../../static/js/jquery-3.3.1.js}"></script>
<script type="text/javascript" src="../../static/js/popper.min.js" th:src="@{../../static/js/popper.min.js}"></script>
<script type="text/javascript" src="../../static/js/bootstrap.min.js" th:src="@{../../static/js/bootstrap.min.js}"></script>
<script type="text/javascript" src="../../static/js/Chart.min.js" th:src="@{../../static/js/Chart.min.js}"></script>
<!-- Icons -->
<script type="text/javascript" src="../../static/js/feather.min.js" th:src="@{../../static/js/feather.min.js}"></script>
<script>
    feather.replace()
</script>
<script>
    var ctx = document.getElementById("myChart");
    var myChart;
    $(function () {
        loadData();
    })
    function loadData()
    {
        $.ajax({
            type: "post",
            url: "/loadData",
            success: function (data) {
                Fill(data);
            }
        });
    }
    function Fill(data) {
        var a=data.analysis;
        var t=data.times;
        console.log(a);
        console.log(t);
        myChart=new Chart(ctx, {
            type: 'line',
            data: {
                labels: [t[6], t[5], t[4], t[3], t[2], t[1], t[0]],
                datasets: [{
                    data: [a[6], a[5], a[4], a[3], a[2], a[1],a[0]],
                    lineTension: 0,
                    backgroundColor: 'transparent',
                    borderColor: '#007bff',
                    borderWidth: 4,
                    pointBackgroundColor: '#007bff'
                }]
            },
            options: {
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero: false
                        }
                    }]
                },
                legend: {
                    display: false,
                }
            }
        });
    }

</script>
</body>
</html>